package com.cheng.example.book.category.thread.client001;

public class Client3 extends Thread {
    public void run()  {
        try {
            sleep(1);  // 延迟50秒
//            while (!isInterrupted()) {
//                System.out.println("isInterrupted");
//            }
//            System.out.println(1);

            while (true) {
//                System.out.println(Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }
    }
    public static void main(String[] args) throws Exception  {
        Thread thread = new Client3();
        thread.start();
        System.out.println("在50秒之内按任意键中断线程!");
        System.in.read();
        thread.interrupt();
        thread.join();
        System.out.println("线程已经退出!");
    }
}
